MCQ Answer

Suppose there is a list such that: l=[2,3,4]. If we want to print this list in reverse order, which of the following methods should be used?

Suppose there is a list such that: l=[2,3,4]. If we want to print this list in reverse order, which of the following methods should be used?

मान लीजिए कि एक लिस्ट ऐसी है: l = [2,3,4]। यदि हम इस लिस्ट को रिवर्स ऑर्डर में प्रिंट करना चाहते हैं, तो निम्न में से किस मैथड का यूज़ किया जाना चाहिए?
Topic : Functions in Python

A. reverse(l) रिवर्स(l)

B. list(reverse[(l)]) लिस्ट(रिवर्स[(l)])

C. reversed(l) रिवर्स्ड(l)

D. list(reversed(l)) लिस्ट(रिवर्स्ड(l))




Correct Answer is :

D. list(reversed(l))



Explanation
The built-in function reversed() can be used to reverse the elements of a list. This function accepts only an iterable as an argument. To print the output in the form of a list, we use: list(reversed(l)). The output will be: [4,3,2].
CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz